package cn.tj212.xiaoyin.core.course.service.impl;

import cn.tj212.xiaoyin.common.page.TailPage;
import cn.tj212.xiaoyin.core.course.dao.CourseSectionDao;
import cn.tj212.xiaoyin.core.course.domain.CourseSection;
import cn.tj212.xiaoyin.core.course.service.ICourseSectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseSectionServiceImpl implements ICourseSectionService {

    @Autowired
    private CourseSectionDao entityDao;

    @Override
    public CourseSection getById(Long sectionId) {
        return entityDao.getById(sectionId);
    }

    @Override
    public List<CourseSection> queryAll(CourseSection queryEntity) {
        return entityDao.queryAll();
    }

    /**
     * 获取课程章最大的sort
     * @param courseId
     * @return
     */
    @Override
    public Integer getMaxSort(Long courseId) {
        return entityDao.getMaxSort(courseId);
    }

    @Override
    public TailPage<CourseSection> queryPage(CourseSection queryEntity, TailPage<CourseSection> page) {
        Integer itemsTotalCount=entityDao.getTotalItemsCount(queryEntity);
        List<CourseSection> items=entityDao.queryPage(queryEntity,page);
        page.setItemsTotalCount(itemsTotalCount);
        page.setItems(items);
        return page;
    }

    @Override
    public void createSelectivity(CourseSection entity) {
        entityDao.createSelectivity(entity);
    }

    @Override
    public void createList(List<CourseSection> entityList) {
        entityDao.createList(entityList);
    }

    @Override
    public void update(CourseSection entity) {
        entityDao.update(entity);
    }

    @Override
    public void updateSelectivity(CourseSection entity) {
        entityDao.updateSelectivity(entity);
    }

    @Override
    public void delete(CourseSection entity) {
        entityDao.delete(entity);
    }

    @Override
    public void deleteLogic(CourseSection entity) {
        entityDao.deleteLogic(entity);
    }

    @Override
    public CourseSection getSortSectionMax(CourseSection curCourseSection) {
        return entityDao.getSortSectionMax(curCourseSection);
    }

    @Override
    public CourseSection getSortSectionMin(CourseSection curCourseSection) {
        return entityDao.getSortSectionMin(curCourseSection);
    }
}
